
<!-- <div class="upload-file-box">
  <notempty name="valArr">
       <volist name="valArr" id="vo">
          <div class="upload-pre-file" data-id="{$vo.id}">
              <span class="upload_icon_all"></span>
              <span>{$vo.name}</span>
              <span class="iconfont icon-cancel cancel-{$id}"></span>
          </div>
       </volist>
  </notempty>
</div> -->
<button type="button" class="btn btn-primary" onclick="addAttribute({$attributes})">添加属性</button>
<div class="attributes">
  <ul>
    <li>
      <div class="col">
        <span>属性名称</span>
      </div>
      <div class="col">
        <span>Attribute Name</span>
      </div>
      <div class="col">
        <span>属性值</span>
      </div>
      <div class="col">
        <span>Attribute Value</span>
      </div>
    </li>
    <volist name="attributes" id="vo">
      <li>
        <div class="col">
          <input type="text" class="form-control" placeholder="属性名称" name="attributes[{$key}][name]" value="{$attributes[$key][name]}">
        </div>
        <div class="col">
          <input type="text" class="form-control" placeholder="Attribute Name" name="attributes[{$key}][name_en]" value="{$attributes[$key][name_en]}">
        </div>
        <div class="col">
          <input type="text" class="form-control" placeholder="属性值" name="attributes[{$key}][value]" value="{$attributes[$key][value]}">
        </div>
        <div class="col">
          <input type="text" class="form-control" placeholder="Attribute Value" name="attributes[{$key}][value_en]" value="{$attributes[$key][value_en]}">
        </div>
        <i class="fa fa-trash trash-{$key}" onclick="deleteAttribute({$key})"></i>
      </li>
    </volist>
  </ul>
</div>
<script type="text/javascript">
  $('.attributes').parent('.controls').parent('.form-item').css('width','100%');
  var attributes_s = '{$attributes_s}';
  var arr_g = JSON.parse(attributes_s);
  var len = arr_g.length;

  function addAttribute(){
    var index = len;
    var li = '<li><div class="col"><input type="text" class="form-control" placeholder="属性名称" name="attributes['+index+'][name]" value="{$attributes['+index+'][name]}"></div><div class="col"><input type="text" class="form-control" placeholder="Attribute Name" name="attributes['+index+'][name_en]" value="{$attributes['+index+'][name_en]}"></div><div class="col"><input type="text" class="form-control" placeholder="属性值" name="attributes['+index+'][value]" value="{$attributes['+index+'][value]}"></div><div class="col"><input type="text" class="form-control" placeholder="Attribute Value" name="attributes['+index+'][value_en]" value="{$attributes['+index+'][value_en]}"></div><i class="fa fa-trash-['+index+']" onclick="deleteAttribute('+index+')"></i></li>';
    $('.attributes ul').append(li);
    len++;
    arr_g.push({});
  }

  function deleteAttribute(index){
    $(".trash-"+index).parent().remove();
    arr_g.splice(index,1);
  }
</script>